package com.ruoyi.system.mapper;

import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.MxSupplier;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 供货商Mapper接口
 *
 * @author ruoyi
 * @date 2024-08-11
 */
public interface MxSupplierMapper {

    @Select("select (SELECT count(0) FROM `mx_supplier`) supplierCount," +
            "(SELECT count(0) FROM `mx_product`) productCount," +
            "(SELECT sum(inventory) from mx_ware) inventory," +
            "(SELECT sum(inventory*price) from mx_ware) money from dual")
    JSONObject getIndexData();

    @Select("SELECT id,CONCAT(`name`,'-',lxr,'-',phone) `value` FROM `mx_supplier`")
    List<JSONObject> allList();


    @Select("select * from (SELECT id,CONCAT(`name`,'-',lxr,'-',phone) `value` FROM `mx_supplier`) t where t.id = #{id}")
    JSONObject allListById(@Param("id") String id);

    /**
     * 查询供货商
     *
     * @param id 供货商主键
     * @return 供货商
     */
    public MxSupplier selectMxSupplierById(Long id);

    /**
     * 查询供货商列表
     *
     * @param mxSupplier 供货商
     * @return 供货商集合
     */
    public List<MxSupplier> selectMxSupplierList(MxSupplier mxSupplier);

    /**
     * 新增供货商
     *
     * @param mxSupplier 供货商
     * @return 结果
     */
    public int insertMxSupplier(MxSupplier mxSupplier);

    /**
     * 修改供货商
     *
     * @param mxSupplier 供货商
     * @return 结果
     */
    public int updateMxSupplier(MxSupplier mxSupplier);

    /**
     * 删除供货商
     *
     * @param id 供货商主键
     * @return 结果
     */
    public int deleteMxSupplierById(Long id);

    /**
     * 批量删除供货商
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteMxSupplierByIds(Long[] ids);
}
